<%layout("/common/_layout.html"){%>
<%#ajax userTable:{%>
<div class="am-cf am-padding" >
  <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">业务管理</strong> / <small>广告管理</small></div>
</div>
<form class="am-form" id="list-form" action="${base}/banner/list" method="post">
 <input type="hidden" id="keywords" name="keywords" value='${keywords!""}' />
 <div class="am-g">
   <div class="am-u-sm-12 am-u-md-6" style="padding:0px 1.6rem 1.6rem 1rem;margin:0px;">
     <div class="am-btn-toolbar">
       <div class="am-btn-group am-btn-group-xs" >
        <%if(so.hasPermission("BANNER_ADD")) {%>
            <button type="button" class="am-btn am-btn-default" onclick="location.href='${base}/banner/add'"><span class="am-icon-plus"></span> 新增</button>
        <%}%>
        <%if(so.hasPermission("BANNER_DELETE")) {%>
            <button type="button" id="deleteButton" disabled="disabled" class="am-btn am-btn-default" onclick="deleteAll('${base}/banner/delete')"><span class="am-icon-trash-o"></span> 删除</button>
        <%}%>         
       </div>
     </div>
   </div>
   <div class="am-u-sm-12 am-u-md-3" >
     <div class="am-input-group am-input-group-sm">
       <input type="text" class="am-form-field" id="name" value="${name!}" placeholder="按名称搜索"/>
       <span class="am-input-group-btn">
         <button id="submit-btn" class="am-btn am-btn-default" type="button">搜索</button>
       </span>
     </div>
   </div>
 </div>
</form>
 <div class="am-g" >
   <div class="am-u-sm-12"><!--  padding:1px 2px 3px 4px;上、右、下,和左   -->
   <div class="am-scrollable-horizontal">
       <table class="am-table am-table-striped am-table-hover table-main">
         <thead>
           <tr class="am-text-nowrap">
             <th class="table-check"><input type="checkbox" id="allCheck"></th>
             <th class="table-id">序号</th>
             <th class="table-title">广告名称</th>
             <th class="table-title">广告类型</th>
             <th class="table-title">排序</th>
             <th class="table-title">商家</th>
             <th class="table-title">广告状态</th>
             <th class="table-set">操作</th>
           </tr>
       </thead>
       <tbody>
       <%for(list in pager.list!){%>
         <tr>
           <td><input type="checkbox" <%{%>name="ids" value="${list.id}"<%}%> /></td>  
           <td>${listLP.index}</td>              
           <td>${list.name}</td>
           <td>
            <%if (list.type == 0){%>
                             外链
            <%}else{%>
                            其它
            <%}%>
           </td>
           <td>${list.sort}</td>
           <td>${list.org_name}</td>
           <td>
              <% if(1 == list.enabled){%>
                                  启用
              <%} else {%>
                                  禁用
              <%}%>
           <td>
             <div class="am-btn-toolbar">
               <div class="am-btn-group am-btn-group-xs">
                <%if(so.hasPermission("BANNER_EDIT")) {%>                   
                 <button type="button" class="am-btn am-btn-default am-btn-xs am-text-secondary" onclick="location.href='${base}/banner/edit?id=${list.id}'"><span class="am-icon-pencil-square-o"></span>编辑</button>
               <%}%>
               </div>
             </div>
           </td>
         </tr>
       <%}%> 
     </tbody>
     </table>
     </div>
       <div class="am-cf">
       <!-- 分页 -->
         <%if (pager.list.~size > 0){%>
             <div class="am-fr">
                 <% include("/admin/common_pager.tpl"){}%>
             </div>
         <%}else{%>
             <div class="am-kai">
               <h3>没有找到任何记录!</h3>
             </div>
         <%}%>
      </div>
      </div>
   </div>
  <%}%>
 <script type="text/javascript">
    $(function(){
      var keywordsObj = {};
      $("#submit-btn").on("click",function(){
        if($("#name").val())
          keywordsObj.name = $("#name").val();
       
        var keywords = "";
        if(!$.isEmptyObject(keywordsObj)){
          keywords = JSON.stringify(keywordsObj);
        }
        console.log("keywords = "+ keywords);

        $("#keywords").val(keywords);
        $("#list-form").submit();
      });
    });
  </script>
<%}%>
